class CreateFavorites < ActiveRecord::Migration
  def self.up
    # I'm not very familiar with migrate,
    # so do the work dirty by using raw SQL.
    # Only works for MySQL!
    execute "CREATE TABLE favorites (
      id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
      user_id INT NOT NULL,
      title VARCHAR(100) NOT NULL,
      url VARCHAR(100) NOT NULL,
      description VARCHAR(300),
      favorite_at DATETIME NOT NULL,
      FOREIGN KEY (user_id) REFERENCES users (id)
    );"
  end

  def self.down
    drop_table :favorites
  end
end
